package scalab.utils

object StringUtils{

	def trim(str: String): String =
		leftTrim(rightTrim(str))

	def leftTrim(str: String): String = {
		var charId: Int = 0
		val strLength = str.length
		while(charId < strLength && Predef.charWrapper(str.charAt(charId)).isWhitespace){
			charId += 1
		}
		str substring charId
	}

	def rightTrim(str: String): String = {
		var charId: Int = str.length - 1
		while(charId >= 0 && Predef.charWrapper(str.charAt(charId)).isWhitespace){
			charId -= 1
		}
		str.substring(0, charId + 1)
	}
}
